package com.huaxin.hxmoduleworkorder.dto.response;

import lombok.Data;

import java.util.List;

@Data
public class InspectionReportGroupByCabinetDTO {
    private String cabinetId;
    private String cabinetName;
    private List<InspectionReportOrderItemDTO> items;
    private boolean hasPhotos;

    // 构造方法中初始化
    public InspectionReportGroupByCabinetDTO(String cabinetId, String cabinetName, List<InspectionReportOrderItemDTO> items) {
        this.cabinetId = cabinetId;
        this.cabinetName = cabinetName;
        this.items = items;
        // 初始化 hasPhotos：只要有一个 item 的 photoUrls 非空，就为 true
        this.hasPhotos = items != null && items.stream()
                .anyMatch(item -> item.getPhotoUrls() != null && !item.getPhotoUrls().isEmpty());
    }

    // ✅ 显式提供 isHasPhotos() —— 这是布尔字段的标准 getter
    public boolean isHasPhotos() {
        return hasPhotos;
    }

    // 可选：保留 getHasPhotos() 兼容旧代码（防坑）
    @Deprecated
    public boolean getHasPhotos() {
        return hasPhotos;
    }
}
